#ifndef AlgBASE_H
#define AlgBASE_H

#include <list>
#include <algorithm>
#include "node.h"
#include "circuit.h"
#include "pareto.h"
#include "place.h"

using namespace std;

class Algorithm{
  public:
		
  Algorithm(Circuit *C, Place *P, int R): Ci(C),TV(0),TVC(0), TVNC(0), pl(P), r(R), test_r(false) {}
        ~Algorithm(){}
	
        Signal* getTraced(int i) {return tracedSigs[i];}
        void addTraced(Signal* s) {tracedSigs.push_back(s);}
        int tracedSize(void) {return tracedSigs.size();}
        void clearTrace(){tracedSigs.clear();}
        
        void initSigs(void);
        void initTracedSigs(void);
        void initGates(void);
        void computeGatesP(void);
        void forward1sig1cycle(Signal* sig);
        void backward1sig1cycle(Signal* sig);
        void forward(void);
        void backward(void);
        float computeTV(void);
        void visCompute(void);
        void traceSelect(unsigned n);
        void printTraces(void);
        void computeForwardWeight(void);
        void computeBackwardWeight(void);
        void computeForwardPathWeight(void);
        void computeBackwardPathWeight(void);
        void hybridComp(void);
        float getTV(void) {return TV;}	
        void printAllsigs();
                
  protected:
        vector<Signal*> tracedSigs;
        Circuit *Ci;
        float TV;
        Place *pl;
		
  public:
        int   r;
        float TVC, TVNC;
        bool  test_r;
};

struct rateStruct{
        int   rate;
        Node* ff;
        bool  fb;
} ;
         
struct moreWeight : public binary_function<rateStruct &, rateStruct &, bool> {
	bool operator()(const rateStruct &a, const rateStruct &b){
		return (a.rate > b.rate);
	}
};

#endif
